local blaze = require "blaze"
local gamelib = require "club.threecard.gamelib"
local game = require "club.threecard.bjracing"

local log = gamelib.logging.get("phase_shower");

local phase_shower = gamelib.ui.element()

phase_shower.app = game;

phase_shower.store_watchers = 
{
    ingame = 
    {
        ["on_phase"] = function(self, store, state, args)
            self:update_phase();
        end,
        ["on_left_time_change"] = function(self, store, state)
            self:update_left_time();
        end
    }
}

function phase_shower:ctor()
    self.res = "club.threecard.bjracing/ui/gamescene.b:phase_shower";
    self.app = game;
end

function phase_shower:update_phase()
    local str = game.store.ingame.get_phase_name();

    self.content_txt.text = string.format("当前游戏阶段：%s", str);
end

function phase_shower:update_left_time()
    self.timer_txt.text = string.format("剩余：%s", game.store.ingame.state.left_time);
end

return phase_shower